<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 15-4-4
 * Time: 下午5:09
 * @author 郑钟良<zzl@ourstu.com>
 */

namespace Group\Widget;

use Group\Model\GroupModel;
use Think\Action;

class UcenterBlockWidget extends Action
{
    public function render($uid = 0, $page = 1, $tab = null, $count = 10)
    {
        !$uid && $uid = is_login();
        //查询条件
        $map['uid']=$uid;
		$map['status']=1;

        $GroupModel = new GroupModel();

        list($list,$totalCount) = $GroupModel->getListByPage($map,$page,'post_count desc','*',$count);
        foreach($list as &$val){
            $val['post'] = D('Group/GroupPost')->where(array('group_id'=>$val['id']))->limit(3)->select();
			$val['type'] = D('Group/GroupType')->getGroupType($val['type_id']);
        }
        unset($val);
        /* 模板赋值并渲染模板 */
        $this->assign('group_list', $list);
        $this->assign('totalCount',$totalCount);

        $this->display(T('Group@Widget/ucenterblock'));
    }
} 